package com.kly.chatter.api.application.controller.chatter;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.kly.chatter.api.application.controller.chatter.res.DashboardRes;
import com.kly.chatter.api.application.service.ChatterDashboardInfoService;
import com.kly.chatter.api.application.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/dashboard")
@Api(value = "/dashboard", tags = "dashboard页面数据")
public class DashboardController {

    @Autowired
    private ChatterDashboardInfoService chatterDashboardInfoService;

    @GetMapping("/detail")
    @ApiOperation(value = "dashboard详情", notes = "dashboard详情")
    @SentinelResource
    public Result<DashboardRes> detail(@RequestParam @ApiParam("chatter userCode") String userCode, @RequestParam @ApiParam("日期 yyyyMMdd") int dateType) {
        DashboardRes dashboardRes = chatterDashboardInfoService.getChatterDashboardInfo(userCode, dateType);
        return Result.ok(dashboardRes);
    }

    @GetMapping("/newDetail")
    @ApiOperation(value = "dashboard详情", notes = "dashboard详情")
    @SentinelResource
    public Result<DashboardRes> newDetail(@RequestParam @ApiParam("chatter userCode") String userCode, @RequestParam @ApiParam("日期 yyyyMMdd") int date) {
        DashboardRes dashboardRes = chatterDashboardInfoService.getChatterDashboardInfo(userCode, date);
        return Result.ok(dashboardRes);
    }

}
